﻿using System;
using System.Collections;
using System.Collections.Generic;
using Me.Prettyprint.Cassandra.Connection;
using Me.Prettyprint.Cassandra.Service;
using Me.Prettyprint.Cassandra.Serializers;
using Me.Prettyprint.Cassandra.Utils;
using Me.Prettyprint.Hector.Api;
using Me.Prettyprint.Hector.Api.Beans;
using Me.Prettyprint.Hector.Api.Query;
using Org.Apache.Cassandra.Thrift;
using Thrift;

namespace Me.Prettyprint.Cassandra.Model
{
    /// <summary>
    /// A Row is a tuple of Key and a column slice. The columns are
    /// defined by the query and can be dynamic or static.
    /// A Row may be used to hold the returned value from queries 
    /// like get_range_slices
    /// </summary>
    /// <typeparam name="K"></typeparam>
    /// <typeparam name="N"></typeparam>
    /// <typeparam name="V"></typeparam>
    public class RowImpl<K, N, V> : Row<K, N, V>
    {
        public RowImpl(K k, List<Column> columns, Serializer<N> nameSerializer,
            Serializer<V> valueSerializer)
        {
            if (k == null || columns == null || nameSerializer == null || valueSerializer == null)
            {
                throw new NullReferenceException("Key, columns, Name serializer and Value serializer cannot be null");
            }
            Key = k;
            ColumnSlice = new ColumnSliceImpl<N, V>(columns, nameSerializer, valueSerializer);
        }

        public K Key
        {
            get; private set;
        }
        public ColumnSlice<N, V> ColumnSlice
        {
            get;
            private set;
        }
        public ColumnSlice<N, V> GetColumnSlice()
        {
            return ColumnSlice;
        }
        public override string ToString()
        {
            return "Row(" + Key + "," + ColumnSlice + ")";
        }

    }
}
